import yaml
import json

data = {
    "数字": [1, -2, 0, 33.0],
    "字符串": ["a", "asdadf", "223_+#$%"],
    "布尔值": [True, False],
    "空值": None,
    "列表": [["a", "b"], ["1", "33", "-3"]],
    "字典": [{"a": 10}, {"v": 33, "d": "cc"}],
    # "集合": [{1, -2, 0, 33.0}, {"sda", "dsf", False}],
}
s_json = json.dumps(data, ensure_ascii=False)  # json字符串
print(s_json)
s_yaml = yaml.dump(data, allow_unicode=True, sort_keys=False)  # yaml字符串
print(s_yaml)

f_json = open("data_json", "w", encoding="utf-8")
f_yaml = open("data_yaml", "w", encoding="utf-8")

f_json.write(s_json)
f_yaml.write(s_yaml)
